关于A^3=X^3+Y^3+Z^3

来源:百度知道 编辑:UC知道 时间:2024/09/23 14:30:39
用VB6.0编程,求使A^3=X^3+Y^3+Z^3(A、X、Y、Z都为正整数)成立的10个最小A的值。
(如6^3=3^3+4^3+5^3, 6就为A的一个值,并且是最小的)

dim a,x,y,z as integer
dim cnt as integer
cnt=0
a=6
while cnt<10
for x=1 to a
for y=x to a
for z=y to a
if int(a^3)<int(x^3)+int(y^3)+int(z^3) then
exit for
elseif int(a^3)=int(x^3)+int(y^3)+int(z^3) then
cnt=cnt+1
msgbox a&"^3="&x&"^3+"&y&"^3+"&z&"^3"
exit for
end if
next
next
next
a=a+1
wend

这个程序我调试成功了